package com.loadburn.heron.complier;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.loadburn.heron.render.Rendering;
import com.loadburn.heron.route.HeronPage;
import com.loadburn.heron.template.TemplateLoader;

/**
 * @author slacrey (scstlinfeng@yahoo.com)
 *         Date: 13-10-28
 */
@Singleton
public class CompilersImpl implements Compilers {

    private final TemplateLoader loader;

    @Inject
    public CompilersImpl(TemplateLoader loader) {
        this.loader = loader;
    }

    @Override
    public void compilePage(HeronPage.Page page) {
        page.applyRender(loader.compile(page));
    }

    @Override
    public Rendering compileClass(Class<?> templateClass) {
        return loader.compile(templateClass);
    }

}
